package engineer.reverse.java;

import design_patterns.command.Command;
import design_patterns.command.CommandQueue2;
import entity_model.Entity;
import entity_model.EntityModel;
import utils.titles.Title;

/**
 * Created by nuno-rafael-figueiredo on 11-07-2014.
 */
public class RevertClass extends Command {
    private EntityModel entityModel;
    private Class<?> aClass;

    public RevertClass(EntityModel entityModel, Class<?> aClass) {
        this.entityModel = entityModel;
        this.aClass = aClass;
    }

    @Override
    public void execute() {
        logger.info(aClass.getSimpleName());
        Entity entity = entityModel.getEntity(Title.fromClass(aClass));

        bind(new CommandQueue2<>(aClass.getDeclaredFields(), field -> new RevertField(entity, field))).execute();
    }
}
